package com.project.dao.impl;

import com.project.bean.UserBean;
import com.project.dao.IUserDao;
import org.springframework.stereotype.Repository;

import java.sql.SQLException;
@Repository
public class UserDaoImpl extends BaseDao implements IUserDao {
    @Override
    public UserBean login(String userName, String password) {
        this.setConnection();
        UserBean user = null;
        try {
            ps = con.prepareStatement("select * from t_user where t_name=? and t_password=?");
            ps.setObject(1,userName);
            ps.setObject(2,password);
            rs = ps.executeQuery();
            if (rs.next()){
                user=new UserBean();
                user.setId(rs.getInt("pk_userId"));
                user.setUserName(rs.getString("t_name"));
                user.setUserPassword(rs.getString("t_password"));
                user.setMinName(rs.getString("t_minName"));
            }
        } catch (Exception e) {
            e.printStackTrace();
        }finally {
            this.closeConnection();
        }
        return user;
    }

}
